<%-- 
    Document   : movieList
    Created on : May 1, 2013, 5:39:55 PM
    Author     : DevSteve
--%>

<%@page import="java.util.List"%>
<%@page import="java.io.FileReader"%>
<%@page import="java.io.IOException"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.FileNotFoundException"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.File"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="db.DB"%>
<%@page import="db.MovieObj"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <title>Dataflix</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta http-equiv="content-language" content="en" />
        <meta name="description" content="" />
        <meta name="language" content="en" />
        <link type="text/css" rel="stylesheet" href="../css/style.css"/>
        <link type="text/css" rel="stylesheet" href="../css/style.css"/>
        <link type-="text/css" rel="stylesheet" href="../css/jquery-ui-1.9.2.custom.min.css"/>
        <link type-="text/css" rel="stylesheet" href="../css/timeline.css"/>
        <link type-="text/css" rel="stylesheet" href="../css/bootstrap.min.css"/>
        <style type="text/css">
            body {
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
        <script src="../js/jquery-1.9.1.min.js"></script>
        <script src="../js/jquery-ui-1.9.2.custom.min.js"></script>
        <script src="../js/bootstrap.min.js"></script>
        <script>
            function editRecord(id) {
                alert(id);
                var f = document.form;
                f.method = "post";
                f.action = 'employeeEdit.jsp?id=' + id;
                f.submit();
            }
        </script>

    <head>
    <body>
        <table id="head">
            <tr>
                <td>
                    <a href="manager.jsp"><img style="margin-left:10%;" src="../images/logoadmin.png"/></a>
                </td>

                <td>
                    <table id="loginbox">
                        <tr>
                            <td width="40%">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <div class="bottom"></div>
        <div class="container-fluid">
            <h3>
                Employee List
                <INPUT Type="BUTTON"  class="btn" value="Add New" onclick="window.location.href = 'createEmployee.jsp';" />

            </h3>

            <table class="table">

                <%

                    java.sql.Connection con;
                    java.sql.Statement s;
                    java.sql.Statement s1;
                    java.sql.ResultSet rs;
                    java.sql.PreparedStatement pst;

                    con = null;
                    s = null;
                    s1 = null;
                    pst = null;
                    rs = null;

                    DB data = new DB();



                    String sql = "SELECT * FROM Users Where Authority=1";
                    try {
                        con = data.getConnection();
                        s = con.createStatement();
                        rs = s.executeQuery(sql);
                %>
                <thead>
                    <tr>
                        <th width="80px;" style=" text-align: center;">Id</th>
                        <th width="250px;" style=" text-align: center;">Email</th>
                        <th width="120px;" style=" text-align: center;">Last Name</th>
                        <th width="180px;" style=" text-align: center;">First Name</th>
                        <th width="200px;" style=" text-align: center;">Address</th>
                        <th width="150px;" style=" text-align: center;">Zip Code</th>
                        <th width="180px;" style=" text-align: center;">SSN</th>
                        <th width="120px;" style=" text-align: center;">Hourly Rate</th>
                        <th width="120px;" style=" text-align: center;">Start Date</th>
                    </tr>
                </thead>

                <tbody id ="gridBody"> 
                    <%
                        while (rs.next()) {
                            String id = rs.getString("Id");
                            String deleteid = "";
                    %><tr>
                        <td name="id<%= id%>" style=" text-align: center;"><%= id%></td>
                        <td style=" text-align: center;"><%= rs.getString("Email")%></td>
                        <td style=" text-align: center;"><%=rs.getString("LastName")%></td>
                        <td style=" text-align: center;"><%=rs.getString("FirstName")%></td>
                        <td style=" text-align: center;"><%=rs.getString("Address")%></td>
                        <td style=" text-align: center;"><%=rs.getString("ZipCode")%></td>
                        <td style=" text-align: center;"><%=rs.getString("SSN").toString()%></td>
                        <td style=" text-align: center;"><%=rs.getString("HourlyRate").toString()%></td>
                        <td style=" text-align: center;"><%=rs.getString("StartDate").toString()%></td>
                        <td style=" text-align: center; "><input type="button" class="btn" value="Edit" onclick="window.location.href = 'editEmployee.jsp?id='+'<%=id%>';" ></td>
                        </td>
                        <td style=" text-align: center; "><INPUT Type="BUTTON" class="btn" value="Delete" onclick="window.location.href = 'deleteEmployee.jsp?id='+'<%=id%>';" />

                        </td>


                    </tr>

                    <%
                        }
                    %>

                    <%



                        } catch (Exception e) {
                            e.printStackTrace();
                        } finally {
                            if (rs != null) {
                                rs.close();
                            }
                            if (s != null) {
                                s.close();
                            }
                            if (con != null) {
                                con.close();
                            }
                        }

                    %>
                </tbody>
            </table>

        </div>
    <body>
</html>



